package org.yyjkcache.common;

import java.time.LocalDateTime;
import java.time.ZoneOffset;

/**
 * 时间工具
 */
public class TimeUtils {
    /**
     * 获取时间(秒数和毫秒数重置为0)
     * @return
     */
    public static long getRoundTime() {
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime roundTime = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), now.getHour(), now.getMinute(), 0);
        return  roundTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
    }
    /**
     * 获取时间(毫秒数重置为0)
     * @return
     */
    public static long getRoundTime(int second) {
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime roundTime = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), now.getHour(), now.getMinute(), second);
        return roundTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
    }
}
